home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / libgimp / gimpproceduraldb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-26  |  4.6 KB  |  173 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpproceduraldb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. #include <string.h>
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_procedural_db_proc_info:
  28.  * @procedure: The procedure name.
  29.  * @blurb: A short blurb.
  30.  * @help: Detailed procedure help.
  31.  * @author: Author(s) of the procedure.
  32.  * @copyright: The copyright.
  33.  * @date: Copyright date.
  34.  * @proc_type: The procedure type.
  35.  * @num_args: The number of input arguments.
  36.  * @num_values: The number of return values.
  37.  * @args: The input arguments.
  38.  * @return_vals: The return values.
  39.  *
  40.  * Queries the procedural database for information on the specified
  41.  * procedure.
  42.  *
  43.  * This procedure returns information on the specified procedure. A
  44.  * short blurb, detailed help, author(s), copyright information,
  45.  * procedure type, number of input, and number of return values are 
  46.  * returned. Additionally this function returns specific information 
  47.  * about each input argument and return value.
  48.  *
  49.  * Returns: TRUE on success.
  50.  */
  51. gboolean
  52. gimp_procedural_db_proc_info (gchar            *procedure,
  53.                   gchar           **blurb,
  54.                   gchar           **help,
  55.                   gchar           **author,
  56.                   gchar           **copyright,
  57.                   gchar           **date,
  58.                   GimpPDBProcType  *proc_type,
  59.                   gint             *num_args,
  60.                   gint             *num_values,
  61.                   GimpParamDef    **args,
  62.                   GimpParamDef    **return_vals)
  63. {
  64.   gint i;
  65.   gboolean success = TRUE;
  66.  
  67.   success = _gimp_procedural_db_proc_info (procedure,
  68.                        blurb,
  69.                        help,
  70.                        author,
  71.                        copyright,
  72.                        date,
  73.                        proc_type,
  74.                        num_args,
  75.                        num_values);
  76.  
  77.   if (success)
  78.     {
  79.       *args        = g_new (GimpParamDef, *num_args);
  80.       *return_vals = g_new (GimpParamDef, *num_values);
  81.  
  82.       for (i = 0; i < *num_args; i++)
  83.         {
  84.           if (! gimp_procedural_db_proc_arg (procedure,
  85.                          i,
  86.                          &(*args)[i].type,
  87.                          &(*args)[i].name,
  88.                          &(*args)[i].description))
  89.             {
  90.               g_free (*args);
  91.               g_free (*return_vals);
  92.  
  93.               return FALSE;
  94.             }
  95.         }
  96.  
  97.       for (i = 0; i < *num_values; i++)
  98.         {
  99.           if (! gimp_procedural_db_proc_val (procedure,
  100.                          i,
  101.                          &(*return_vals)[i].type,
  102.                          &(*return_vals)[i].name,
  103.                          &(*return_vals)[i].description))
  104.             {
  105.               g_free (*args);
  106.               g_free (*return_vals);
  107.  
  108.               return FALSE;
  109.             }
  110.         }
  111.      }
  112.  
  113.   return success;
  114. }
  115.  
  116. /**
  117.  * gimp_procedural_db_get_data:
  118.  * @identifier: The identifier associated with data.
  119.  * @data: A byte array containing data.
  120.  *
  121.  * Returns data associated with the specified identifier.
  122.  *
  123.  * This procedure returns any data which may have been associated with
  124.  * the specified identifier. The data is copied into the given memory 
  125.  * location.
  126.  *
  127.  * Returns: TRUE on success, FALSE if no data has been associated with 
  128.  * the identifier
  129.  */
  130. gboolean
  131. gimp_procedural_db_get_data (gchar    *identifier,
  132.                  gpointer  data)
  133. {
  134.   gint      size;
  135.   guint8   *hack;
  136.   gboolean  success;
  137.  
  138.   success = _gimp_procedural_db_get_data (identifier,
  139.                       &size,
  140.                       &hack);
  141.   if (hack)
  142.     {
  143.       memcpy (data, (gpointer) hack, size * sizeof (guint8));
  144.       g_free (hack);
  145.     }
  146.   
  147.   return success;
  148. }
  149.  
  150. /**
  151.  * gimp_procedural_db_set_data:
  152.  * @identifier: The identifier associated with data.
  153.  * @data: A byte array containing data.
  154.  * @bytes: The number of bytes in the data
  155.  *
  156.  * Associates the specified identifier with the supplied data.
  157.  *
  158.  * This procedure associates the supplied data with the provided
  159.  * identifier. The data may be subsequently retrieved by a call to
  160.  * 'procedural-db-get-data'.
  161.  *
  162.  * Returns: TRUE on success.
  163.  */
  164. gboolean
  165. gimp_procedural_db_set_data (gchar    *identifier,
  166.                  gpointer  data,
  167.                  guint32   bytes)
  168. {
  169.   return _gimp_procedural_db_set_data (identifier,
  170.                        bytes,
  171.                        data);
  172. }
  173.